package modellayer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class Loan {
	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	private Date borrowDate;
	private ArrayList<SubLoan> subLoans;
	private static int nextID = 0;
	private int id;

	/**
	 * the constructor of class Loan
	 * 
	 */
	public Loan() 
	{
		nextID++;
		id = nextID;
		borrowDate = new Date();
		subLoans = new ArrayList<SubLoan>();
	}
	/**
	 * @return the id
	 */
	public int getId() 
	{
		return id;
	}
	/**
	 * @return the borrowDate
	 */	
	public Date getBorrowDate() 
	{
		return borrowDate;
	}

	/**
	 * @param l SubLoan
	 */
	public void addSubLoan(SubLoan l)
	{
		subLoans.add(l);
	}

	/**
	 * @param l SubLoan
	 */
	public void deleteSubLoan(SubLoan l)
	{
		subLoans.remove(l);
	}

	/**
	 * Gets the sub loans.
	 *
	 * @return the sub loans
	 */
	public ArrayList<SubLoan> getSubLoans()
	{
		return subLoans;
	}
}
